require 'network/player_connection'
require 'observer'

class MockConnection < PlayerConnection
    def initialize(echo=false)
        @echo = echo
        class << $stdin# {{{
            include Observable
            def subscribe(s)
                @s = s
            end
            def update(s)
                @s.update(s)
            end
        end# }}}
        super($stdin)
    end

    def prompt(s)
        puts s if @echo
        update(gets)
    end
    def send_string(s)
        puts s if @echo
    end
    def handler
        @handlers.top.dup
    end
end
